package com.givemepass.FragmentTabs;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Fragment1ViewDetail extends Fragment {
	
	private String act_no;
	private String act_name;
	private String time;
	private String host;
	private String place;
	private String intro;
	private String condition;
	private String host_name;
	private String host_tel;
	private String host_mail;
	private String account;
	private String deadline;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v = inflater.inflate(R.layout.fragment1_view_detail, container, false);
		
		act_no = getArguments().getString("act_no");
		act_name = getArguments().getString("act_name");
		time = getArguments().getString("time");
		host = getArguments().getString("host");
		place = getArguments().getString("place");
		intro = getArguments().getString("introduction");
		condition = getArguments().getString("condition");
		host_name = getArguments().getString("host_name");
		host_tel = getArguments().getString("host_tel");
		host_mail = getArguments().getString("host_email");
		account = getArguments().getString("account");
		deadline = getArguments().getString("deadline");
		
		TextView actNoText = (TextView)v.findViewById(R.id.act_no);
		actNoText.setText(act_no);
		TextView actNameText = (TextView)v.findViewById(R.id.act_name);
		actNameText.setText(act_name);
		TextView actTimeText = (TextView)v.findViewById(R.id.time);
		actTimeText.setText(time);
		TextView actHostText = (TextView)v.findViewById(R.id.host);
		actHostText.setText(host);
		TextView actPlaceText = (TextView)v.findViewById(R.id.place);
		actPlaceText.setText(place);
		TextView actIntroText = (TextView)v.findViewById(R.id.intro);
		actIntroText.setText(intro);
		TextView actConditionText = (TextView)v.findViewById(R.id.condition);
		actConditionText.setText(condition);
		TextView Host_nameText = (TextView)v.findViewById(R.id.host_name);
		Host_nameText.setText(host_name);
		TextView Host_telText = (TextView)v.findViewById(R.id.host_tel);
		Host_telText.setText(host_tel);
		TextView Host_mailText = (TextView)v.findViewById(R.id.host_mail);
		Host_mailText.setText(host_mail);
		TextView actDeadline = (TextView)v.findViewById(R.id.deadline);
		actDeadline.setText(deadline);
		
		Button btJoinIn = (Button) v.findViewById(R.id.joinIn);
        ((Button) btJoinIn).setOnClickListener(new OnClickListener() {
	
        	@Override
			public void onClick(View v) {          

				// TODO Auto-generated method stub
				Bundle args = new Bundle();
				args.putString("act_no", act_no);
				args.putString("act_name", act_name);
				args.putString("account", account);

    	        Fragment newFragment = new Fragment1ViewJoinIn();
     	       
	        	FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
	        	newFragment.setArguments(args);
	        	   
	        	ft.replace(R.id.realtabcontent, newFragment);
	            ft.setTransition(FragmentTransaction.TRANSIT_NONE);
	            ft.addToBackStack(null);
	            ft.commit();
			}
        });

		return v;
	}

}
